package pers.sloera.nowcoder.maze;

import java.util.Scanner;

/**
 * class pers.sloera.nowcoder.maze
 * user sloera
 * date 2022/3/6
 * 60
 */
public class Main {
    public static void main(String[] args) {
        // 6 4
        // 5
        // 0 2
        // 1 2
        // 2 2
        // 4 1
        // 5 1

        // 2 3
        Scanner in = new Scanner(System.in);
        String coordinate = "";
        if (in.hasNextLine()) {
            coordinate = in.nextLine();
        }
        final String[] s = coordinate.split(" ");
        final int x = Integer.parseInt(s[0]);
        final int y = Integer.parseInt(s[1]);
        boolean[][] map = new boolean[x][y];
        // 不可达
        boolean[][] unReachAble = new boolean[Integer.parseInt(s[0])][y];
        // 陷阱
        boolean[][] trap = new boolean[Integer.parseInt(s[0])][y];
        String wallNumberStr = "";
        if (in.hasNextLine()) {
            wallNumberStr = in.nextLine();
        }
        int wallNumber = Integer.parseInt(wallNumberStr);
        for (int i = 0; i < wallNumber; i++) {
            final String s1 = in.nextLine();
            final String[] s2 = s1.split(" ");
            map[Integer.parseInt(s2[0])][Integer.parseInt(s2[1])] = true;
        }
        // System.out.println();
        int i = 0, j = 0;
        unReachDp(map, unReachAble, 0, 0);
        trapDp(map, trap, x - 1, y - 1);
        // System.out.println();
        int trapNum = 0, unReachAbleNum = 0;
        for (int k = 0; k < trap.length; k++) {
            for (int l = 0; l < trap[k].length; l++) {
                if (trap[k][l] && !map[k][l]) {
                    trapNum++;
                }
            }
        }
        for (int k = 0; k < unReachAble.length; k++) {
            for (int l = 0; l < unReachAble[k].length; l++) {
                if (unReachAble[k][l] && !map[k][l]) {
                    unReachAbleNum++;
                }
            }
        }
        System.out.print(trapNum + " " + unReachAbleNum);
    }

    private static void unReachDp(boolean[][] map, boolean[][] unReachAble, int i, int j) {
        // 越界
        if (i >= map.length || j >= map[0].length) {
            return;
        }
        if (map[i][j]) {
            unReachAble[i][j] = true;
        } else {
            if (i == 0 && j == 0) {
            } else {
                if (i > 0 && j > 0) {
                    unReachAble[i][j] = unReachAble[i - 1][j] & unReachAble[i][j - 1];
                } else {
                    if (i == 0) {
                        unReachAble[i][j] = unReachAble[i][j - 1];
                    } else {
                        unReachAble[i][j] = unReachAble[i - 1][j];
                    }
                }
            }
        }
        unReachDp(map, unReachAble, i + 1, j);
        unReachDp(map, unReachAble, i, j + 1);
    }

    private static void trapDp(boolean[][] map, boolean[][] trap, int i, int j) {
        // 越界
        if (i < 0 || j < 0) {
            return;
        }
        if (map[i][j]) {
            trap[i][j] = true;
        } else {
            if (i < map.length - 1 && j < map[0].length - 1) {
                trap[i][j] = trap[i + 1][j] & trap[i][j + 1];
            } else {
                if (i == map.length - 1 && j < map[0].length - 1) {
                    trap[i][j] = trap[i][j + 1];
                }
                if (j == map[0].length - 1 && i < map.length - 1) {
                    trap[i][j] = trap[i + 1][j];
                }
            }
        }
        trapDp(map, trap, i - 1, j);
        trapDp(map, trap, i, j - 1);
    }
}

